﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace UnionManager.Models
{
    public class Account : BaseModel, IAccount
    {
        public TAIKHOAN ValidateUser(string loginName, string password)
        {
            return DB.TAIKHOANs.FirstOrDefault(u => u.TenDangNhap == loginName && u.MatKhau == password && u.TrangThai == true);
        }
        public TAIKHOAN FindAccountID(string name)
        {
           return DB.TAIKHOANs.FirstOrDefault(u => u.TenDangNhap == name);
        }
        public int InsertAccount(TAIKHOAN tk)
        {
            try
            {
                DB.AddToTAIKHOANs(tk);
                CommitChanges();
                return tk.Id_Taikhoan;
            }
            catch (System.Exception ex)
            {
                return 0;
            }

        }
    }
}